package com.limao.DBProvider;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import com.limao.DBDataClass.CrowdVRHomeClass;
import com.limao.DbConnection.DbConnectionManager;

public class CrowdVRHomeProvider {

	private static CrowdVRHomeProvider instance;

	public static CrowdVRHomeProvider getInstance() {
		if(instance==null) instance=new CrowdVRHomeProvider();
		return instance;
	}
	
  
	private CrowdVRHomeProvider() {

	}

	private CrowdVRHomeClass encapOrderData(ResultSet rs) throws Exception{
		
		CrowdVRHomeClass orderData = new CrowdVRHomeClass();
		
		orderData.vrid=rs.getString("vrid");
		orderData.vrcompany=rs.getString("vrcompany");
		orderData.vrlogo=rs.getString("vrlogo");
		orderData.vrok=rs.getString("vrok");
		orderData.vrrisk=rs.getString("vrrisk");
		orderData.vrrisk1=rs.getString("vrrisk1");
		
		orderData.vradv0=rs.getString("vradv0");
		orderData.vradv1=rs.getString("vradv1");
		orderData.vradv2=rs.getString("vradv2");
		orderData.vradv3=rs.getString("vradv3");
		orderData.openuser=rs.getString("openuser");
		
		orderData.iscommon=rs.getString("iscommon");
		orderData.commonrate=rs.getString("commonrate");
		orderData.marate=rs.getString("marate");
		orderData.type=rs.getString("type");
		orderData.vraddress=rs.getString("vraddress");
		orderData.vrtel=rs.getString("vrtel");		
		


		
		return orderData;
	}
			
	public CrowdVRHomeClass Load_CrowdVR()
	{
		CrowdVRHomeClass tmp=null;
		Connection con = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
			try {
				 
				con = DbConnectionManager.getConnection();
				pstmt = con.prepareStatement("select * from vr_sys_company where vrok=1 order by vrid desc limit 1 ");
				rs = pstmt.executeQuery();
				if (rs.next()) {
					tmp=encapOrderData(rs);
				}

			} catch (Exception e) {
				e.printStackTrace();
				tmp=null;
			} finally {
				DbConnectionManager.closeConnection(rs, pstmt, con);
			}
			return tmp;
	}
	


	
}
